//
//  UILable + Extension.swift
//  Weibo
//
//  Created by apple on 15/12/10.
//  Copyright © 2015年 idcast. All rights reserved.
//

import UIKit

extension UILabel {

    ///遍历构造函数
    
    convenience init(title: String,
        fontSize: CGFloat = 14,
        color: UIColor = UIColor.darkGrayColor(),
        screenInset: CGFloat = 0) {//相对于屏幕左右的锁紧 默认是0 居中显示 如果设置则左对齐
        
        self.init()
            
        text = title
        
        textColor = color
            
        font = UIFont.systemFontOfSize(fontSize)
            
        numberOfLines = 0
            if screenInset == 0 {
            
                textAlignment = NSTextAlignment.Center
            }else {
                //设置换行宽度
                preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * screenInset
                textAlignment = .Left
            }
    }
}


